home *** CD-ROM | disk | FTP | other *** search
/ Apple II Magazines (PO) / Nibble Volume 09, No. 11 (1988-11)(MicroSPARC)(Side A)[a].zip / Nibble Volume 09, No. 11 (1988-11)(MicroSPARC)(Side A)[a].po / START.RAW.ASM.txt < prev    next >
Text File  |  1996-12-24  |  9KB  |  246 lines

  1. ***********************************
  2. *                                 *
  3. *         */SYSTEM/START          *
  4. *            Raw Code             *
  5. *  Interpreted by Sandy Mossberg  *
  6. *                                 *
  7. *       Copyright (C) 1988        *
  8. *       by MicroSPARC, Inc.       *
  9. *       Concord, MA  01742        *
  10. *                                 *
  11. ***********************************
  12.  
  13. ; Equates:
  14.  
  15. LCONST     GEQU     $F2              ;program code/data record
  16. cRELOC     GEQU     $F5              ;compressed reloc record
  17. SUPER      GEQU     $F7              ;super compressed reloc rec
  18. RELOC3     GEQU     $01              ;relocate 3 bytes (SUPER)
  19. PRODOS     GEQU     $E100A8          ;ProDOS 16 call
  20.  
  21. Start_File START
  22.  
  23. *****************************************************************
  24. *
  25. * Segment 1 Header:
  26. *
  27. Start_Head ANOP
  28.  
  29. BYTECNT    DC       I4'$111'         ;total size of segment= 273
  30. RESSPC     DC       I4'$00'          ;# zeros added at EOF= 0
  31. LENGTH     DC       I4'$A6'          ;size of loaded segment= 166
  32. UNDEF1     DC       I1'$FF'          ;undefined
  33. LABLEN     DC       I1'$0A'          ;maximum label length= 10
  34. NUMLEN     DC       I1'$04'          ;number length always= 4
  35. VERSION    DC       I1'$02'          ;OMF version= 2
  36. BANKSIZE   DC       I4'$10000'       ;maximum bank size= 65536
  37. KIND       DC       I2'$00'          ;type/attrib (static code)
  38. UNDEF2     DC       I2'$00'          ;undefined
  39. ORG        DC       I4'$00'          ;load address (relocatable)
  40. ALIGN      DC       I4'$00'          ;page alignment (unaligned)
  41. NUMSEX     DC       I1'$00'          ;byte order (lo/hi)
  42. UNDEF3     DC       I1'$00'          ;undefined
  43. SEGNUM     DC       I2'$01'          ;segment number= 1
  44. ENTRY      DC       I4'$00'          ;entry offset= 0
  45. DISPNAME   DC       I2'$2C'          ;offset of LOADNAME= 44
  46. DISPDATA   DC       I2'$40'          ;offset of segment body= 64
  47. LOADNAME   DC       10C' '           ;name of load segm (unused)
  48. SEGNAME    DC       10C' '           ;name of this segm (unused)
  49.  
  50. *****************************************************************
  51. *
  52. * Segment 1 Body:
  53. *
  54. ;................................................................
  55. ;
  56. ; Record 1 Operation Code and Data:
  57. ;
  58.            DC       I1'LCONST'       ;operation code= LCONST
  59.            DC       I4'$A6'          ;byte count= 166
  60. ;................................................................
  61. ;
  62. ; Record 1 Program Code:
  63. ;
  64. ; Equate data bank to program bank:
  65.  
  66. Start_Body PHK
  67.            PLB
  68.  
  69. ; Calculate amount of usable RAM:
  70.  
  71.            PHA                       ;reserve work area on
  72.            PHA                       ; stack (4 bytes)
  73.            JSL      >GoGetRAM-PO     ;get size of usable RAM
  74. ;                                    ;** relocated by SUPER
  75.            LDA      $03,S            ;result left on stack
  76.            CMP      #4
  77.            BCC      AltQuit          ;less than 256K found
  78.  
  79. ; Primary QUIT command:
  80.  
  81.            JSL      PRODOS           ;used if >= 256K usable RAM
  82.            DC       I2'$29'          ;QUIT command code
  83. MQParmPtr  DC       I4'MQuitParm-PO' ;pointer to parmlist
  84. ;                                    ;** relocated by cRELOC
  85.  
  86. ; Alternate QUIT command:
  87.  
  88. AltQuit    JSL      PRODOS           ;used if < 256K usable RAM
  89.            DC       I2'$29'          ;QUIT command code
  90. AQParmPtr  DC       I4'AQuitParm-PO' ;pointer to parmlist
  91. ;                                    ;** relocated by cRELOC
  92.  
  93. ; Primary QUIT parameter list:
  94.  
  95. MQuitParm  DC       I4'MQuitName-PO' ;pointer to pathname
  96. ;                                    ;** relocated by cRELOC
  97.            DC       I2'$00'          ;return/restart flags
  98.  
  99. ; Alternate QUIT parameter list:
  100.  
  101. AQuitParm  DC       I4'AQuitName-PO' ;pointer to pathname
  102. ;                                    ;** relocated by cRELOC
  103.            DC       I2'$00'          ;return/restart flags
  104.  
  105. ; Pathname of primary START file:
  106.  
  107. MQuitName  DC       I1'$0F'          ;length byte
  108.            DC       C'*/SYSTEM/FINDER'
  109.  
  110. ; Pathname of alternate START file:
  111.  
  112. AQuitName  DC       I1'$11'          ;length byte
  113.            DC       C'*/SYSTEM/LAUNCHER'
  114.  
  115. ; Call subroutine to calculate usable RAM:
  116. ;
  117. ; EXIT: usable RAM on stack bytes 1-4 (L-ML-MH-H):
  118.  
  119. GoGetRAM   JSL      >GetRAM-PO       ;get size of usable RAM
  120. ;                                    ;** relocated by SUPER
  121.            RTL
  122.  
  123. ; Subroutine to calculate usable RAM:
  124. ;
  125. ; EXIT: usable RAM on stack bytes 4-7 (L-ML-MH-H):
  126.  
  127. ;--> Transform stack into work area for calculations:
  128.  
  129. GetRAM     PHD                       ;save entry direct page
  130.            PHA                       ;save return address
  131.            PHA                       ; on stack
  132.            TSC                       ;equate stack and
  133.            TCD                       ; direct page
  134.            STZ      $0D              ;zero storage bytes for
  135.            STZ      $0F              ; RAM calculations
  136.  
  137. ;--> Point to Memory Manager's allocated block records:
  138.  
  139.            LDA      $E11600
  140.            TAX
  141.            LDA      $E11602
  142. GR1        STX      $01              ;pointers to block records
  143.            STA      $03              ; at $00-$03
  144.  
  145. ;--> Test block attributes:
  146.  
  147.            LDY      #4
  148.            LDA      [$01],Y          ;get attributes
  149.            AND      #$0300           ;isolate purge level
  150.            BNE      GR2              ;block purgeable so skip it
  151.  
  152. ;--> Calculate total size of unpurgeable (unusable) RAM:
  153.  
  154.            LDY      #8               ;block unpurgeable
  155.            LDA      [$01],Y          ;get block size lo
  156.            CLC                       ; and save it
  157.            ADC      $0D              ; at $0C-$0D of
  158.            STA      $0D              ; direct page (also stack)
  159.            INY                       ;bump index to
  160.            INY                       ; hi order byte
  161.            LDA      [$01],Y          ;get block size hi
  162.            ADC      $0F              ; and save it
  163.            STA      $0F              ; at $0E-$0F of
  164. GR2        LDY      #$10             ; direct page (also stack)
  165.            LDA      [$01],Y          ;get link lo to next
  166.            TAX                       ; block record
  167.            INY                       ;bump index to
  168.            INY                       ; hi order byte
  169.            LDA      [$01],Y          ;get link to to next record
  170.            BNE      GR1              ;not at last record
  171.  
  172. ;--> Subtract from $100000000 to get total usable RAM:
  173.  
  174.            LDA      #0               ;all block records checked
  175.            TAX                       ; so calculate complement
  176.            SEC                       ; of total block sizes
  177.            SBC      $0D              ; stored at $0C-$0F
  178.            STA      $0D
  179.            TXA
  180.            SBC      $0F
  181.            STA      $0F
  182.            PLA                       ;restore return address and
  183.            PLA                       ; direct page to entry
  184.            PLD                       ; values (former $0C-$0F at
  185.            RTL                       ; $04-$07 after RTL)
  186.  
  187. PO         EQU      Start_Body-Start_Head
  188.  
  189. *****************************************************************
  190. *
  191. * Segment 1 Relocation Dictionary:
  192. *
  193. ;................................................................
  194. ;
  195. ; Record 2 Operation Code and Data:
  196. ;
  197.            DC       I1'cRELOC'       ;operation code= cRELOC
  198.            DC       I1'$04'          ;# bytes to relocate= 4
  199.            DC       I1'$00'          ;bit-shift operator= none
  200.            DC       I2'MQParmPtr-PO' ;offset of code to reloc= 21
  201.            DC       I2'MQuitParm-PO' ;offset to reloc addr= 35
  202. ;................................................................
  203. ;
  204. ; Record 3 Operation Code and Data:
  205. ;
  206.            DC       I1'cRELOC'       ;operation code= cRELOC
  207.            DC       I1'$04'          ;# bytes to relocate= 4
  208.            DC       I1'$00'          ;bit-shift operator= none
  209.            DC       I2'AQParmPtr-PO' ;offset of code to reloc= 31
  210.            DC       I2'AQuitParm-PO' ;offset to reloc addr= 41
  211. ;................................................................
  212. ;
  213. ; Record 4 Operation Code and Data:
  214. ;
  215.            DC       I1'cRELOC'       ;operation code= cRELOC
  216.            DC       I1'$04'          ;# bytes to relocate= 4
  217.            DC       I1'$00'          ;bit-shift operator= none
  218.            DC       I2'MQuitParm-PO' ;offset of code to reloc= 35
  219.            DC       I2'MQuitName-PO' ;offset to reloc addr= 47
  220. ;................................................................
  221. ;
  222. ; Record 5 Operation Code and Data:
  223. ;
  224.            DC       I1'cRELOC'       ;operation code= cRELOC
  225.            DC       I1'$04'          ;# bytes to relocate= 4
  226.            DC       I1'$00'          ;bit-shift operator= none
  227.            DC       I2'AQuitParm-PO' ;offset of code to reloc= 41
  228.            DC       I2'AQuitName-PO' ;offset to reloc addr= 63
  229. ;................................................................
  230. ;
  231. ; Record 6 Operation Code and Data:
  232. ;
  233.            DC       I1'SUPER'        ;operation code= SUPER
  234.            DC       I4'$04'          ;# bytes left in record= 4
  235.            DC       I1'RELOC3'       ;type= RELOC3
  236.            DC       I1'$01'          ;# patches-1= 2 patches
  237.            DC       I1'$05'          ;patch 1 offset= 5
  238.            DC       I1'$52'          ;patch 2 offset= 82
  239. ;................................................................
  240. ;
  241. ; Record 7 Operation Code:
  242. ;
  243.            DC       H'00'            ;operation code= END
  244.  
  245.            END
  246.